<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>max_execution_time测试脚本</title>
</head>
<body>
<div>
    <div><h1>测试脚本说明</h1></div>
    <div>由于在UNIX系统中，使用sleep函数并不能够测试max_execution_time，故有此脚本。</div>
    <div>SVN Id: $Id: max_execution_time_test.php 186 2011-05-25 11:27:03Z horseluke@126.com $</div>
</div>

<div>
    <div><h1><a href="http://cn.php.net/manual/en/function.set-time-limit.php" target="_blank">PHP文档说明原文抄录</a></h1></div>
    <div>The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself.
        <br />Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. 
        <br />This is not true on Windows where the measured time is real. 
    </div>
</div>


<div>
    <div><h1>测试区</h1></div>
</div>
<?php
@ob_start();
echo "Max execution time: ".ini_get("max_execution_time")."<br />";
echo "Max input time: ".ini_get("max_input_time")."<br />";
echo 'BEGIN TEST<br />';
flush_buffers();

$max_test_second = 50;    //要测试多少秒

$process  = $process_before =  0;
$a = array();

$start = time();

while($process <= $max_test_second){
	$process = time() - $start;
	if($process  != $process_before){
		echo $process_before. '<br />';
		flush_buffers();
		
		$process_before = $process;
	}
	$a[1] = mt_rand(1, 10000);
}

echo 'TEST END';


function flush_buffers(){
	@ob_end_flush();
	@ob_flush();
	@flush();
	@ob_start();
}
?>

</body>
</html>